<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>vue</title>
    <script src='https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js'></script>
    <style type="text/css">
        * {
            margin: 0px;
            padding: 0px;
        }

        html,
        body {
            width: 100%;
            height: 100%;
        }

        footer ul {
            display: flex;
            position: fixed;
            left: 0px;
            bottom: 0px;
            width: 100%;
            height: 40px;
        }

        footer ul li {
            flex: 1;
            text-align: center;
            list-style: none;
            height: 40px;
            line-height: 40px;
            background: gray;
            color: white;
        }
    </style>
</head>

<body>
    <div id='app'>
        <h1>微信</h1>
        <!-- 
        <wechat v-show="which === 'wechat'"></wechat>
        <tel v-show="which === 'tel'"></tel>
        <discover v-show="which === 'discover'"></discover> -->

        <!-- 动态组件等效写法 -->
        <!-- <component is="wechat"></component> -->
        <!-- 属性绑定 -->
        <!-- <component :is="which"></component> -->

        <!-- 动态组件：每次切换组件，重新删除，并创建新组件 -->

        <!-- 缓存组件 -->
        <keep-alive>
            <component :is="which"></component>
        </keep-alive>

        <footer>
            <ul>
                <li @click="which = 'wechat'">微信</li>
                <li @click="which = 'tel'">通讯录</li>
                <li @click="which = 'discover'">发现</li>
            </ul>
        </footer>
    </div>
</body>
<script>
    Vue.component('wechat', {
        template: `
            <div>
                微信
                <input type='search'/>
            </div>    
        `
    });
    Vue.component('tel', {
        template: `
            <div>
                通信录
            </div>    
        `
    });
    Vue.component('discover', {
        template: `
            <div>
                发现
            </div>    
        `
    });

    let vm = new Vue({
        el: '#app',
        data: {
            which: 'wechat'
        }
    });
</script>

</html>